﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SharpSoft.Html
{
    public static class FetchingExtensions
    {
        ///// <summary>
        ///// 获取指定属性路径的属性值
        ///// </summary>
        ///// <param name="pvs"></param>
        ///// <param name="pp"></param>
        ///// <returns></returns>
        //public static object GetValue(this HtmlFetchingPropertyValue[] pvs,PropertyPath pp)
        //{
        //    HtmlFetchingPropertyValue
        //    foreach (var item in pp)
        //    {
        //        var pv = pvs.GetPropertyValue(pp);
        //    }

        //}
        public static HtmlFetchingPropertyValue GetPropertyValue(this HtmlFetchingPropertyValue[] pvs, string propertyname)
        {
            if (pvs == null)
            {
                return null;
            }
            foreach (var item in pvs)
            {
                if (item.name == propertyname)
                {
                    return item;
                }
            }
            return null;
        }
        /// <summary>
        /// 连接基础url和相对url
        /// </summary>
        /// <param name="baseurl"></param>
        /// <param name="relurl"></param>
        /// <returns></returns>
        public static string CombineUrl(string baseurl, string relurl)
        {
            var bu = new Uri(baseurl);
            var u = new Uri(bu, relurl);
            return u.ToString();
        }
    }
}
